<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
<title>Basic JAXB Examples - The Java EE 5 Tutorial</title>
<meta name="robots" content="index,follow">
<meta name="robots" content="index,follow">
<meta name="date" content="2008-10-01">
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel="stylesheet" type="text/css" href="css/ipg.css">
<link rel="stylesheet" type="text/css" href="css/j5eetutorial.css">
</head>

<body>

<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody>
   <tr valign="top">
      <td><p class="toc level1"><a href="docinfo.html">Document Information</a></p>
<p class="toc level1 tocsp"><a href="gexaf.html">Preface</a></p>
<p class="toc level1 tocsp"><a href="gfirp.html">Part&nbsp;I&nbsp;Introduction</a></p>
<p class="toc level2"><a href="bnaaw.html">1.&nbsp;&nbsp;Overview</a></p>
<p class="toc level2"><a href="gfiud.html">2.&nbsp;&nbsp;Using the Tutorial Examples</a></p>
<p class="toc level1 tocsp"><a href="bnadp.html">Part&nbsp;II&nbsp;The Web Tier</a></p>
<p class="toc level2"><a href="bnadr.html">3.&nbsp;&nbsp;Getting Started with Web Applications</a></p>
<p class="toc level2"><a href="bnafd.html">4.&nbsp;&nbsp;Java Servlet Technology</a></p>
<p class="toc level2"><a href="bnagx.html">5.&nbsp;&nbsp;JavaServer Pages Technology</a></p>
<p class="toc level2"><a href="bnajo.html">6.&nbsp;&nbsp;JavaServer Pages Documents</a></p>
<p class="toc level2"><a href="bnakc.html">7.&nbsp;&nbsp;JavaServer Pages Standard Tag Library</a></p>
<p class="toc level2"><a href="bnalj.html">8.&nbsp;&nbsp;Custom Tags in JSP Pages</a></p>
<p class="toc level2"><a href="bnaon.html">9.&nbsp;&nbsp;Scripting in JSP Pages</a></p>
<p class="toc level2"><a href="bnaph.html">10.&nbsp;&nbsp;JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="bnaqz.html">11.&nbsp;&nbsp;Using JavaServer Faces Technology in JSP Pages</a></p>
<p class="toc level2"><a href="bnatx.html">12.&nbsp;&nbsp;Developing with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="bnavg.html">13.&nbsp;&nbsp;Creating Custom UI Components</a></p>
<p class="toc level2"><a href="bnawo.html">14.&nbsp;&nbsp;Configuring JavaServer Faces Applications</a></p>
<p class="toc level2"><a href="bnaxu.html">15.&nbsp;&nbsp;Internationalizing and Localizing Web Applications</a></p>
<p class="toc level1 tocsp"><a href="bnayk.html">Part&nbsp;III&nbsp;Web Services</a></p>
<p class="toc level2"><a href="bnayl.html">16.&nbsp;&nbsp;Building Web Services with JAX-WS</a></p>
<p class="toc level2"><a href="bnazf.html">17.&nbsp;&nbsp;Binding between XML Schema and Java Classes</a></p>
<p class="toc level3"><a href="bnazg.html">JAXB Architecture</a></p>
<p class="toc level4"><a href="bnazg.html#bnazh">Architectural Overview</a></p>
<p class="toc level4"><a href="bnazg.html#bnazj">The JAXB Binding Process</a></p>
<p class="toc level4"><a href="bnazg.html#bnazl">More about Unmarshalling</a></p>
<p class="toc level4"><a href="bnazg.html#bnazm">More about Marshalling</a></p>
<p class="toc level4"><a href="bnazg.html#bnazn">More about Validation</a></p>
<p class="toc level3 tocsp"><a href="bnazo.html">Representing XML Content</a></p>
<p class="toc level4"><a href="bnazo.html#bnazp">Java Representation of XML Schema</a></p>
<p class="toc level3 tocsp"><a href="bnazq.html">Binding XML Schemas</a></p>
<p class="toc level4"><a href="bnazq.html#bnazr">Simple Type Definitions</a></p>
<p class="toc level4"><a href="bnazq.html#bnazs">Default Data Type Bindings</a></p>
<p class="toc level5"><a href="bnazq.html#bnazt">Schema-to-Java Mapping</a></p>
<p class="toc level5"><a href="bnazq.html#bnazv"><tt>JAXBElement</tt> Object</a></p>
<p class="toc level5"><a href="bnazq.html#bnazw">Java-to-Schema Mapping</a></p>
<p class="toc level3 tocsp"><a href="bnazy.html">Customizing Generated Classes and Java Program Elements</a></p>
<p class="toc level4"><a href="bnazy.html#bnazz">Schema-to-Java</a></p>
<p class="toc level4"><a href="bnazy.html#bnbaa">Java-to-Schema</a></p>
<p class="toc level3 tocsp"><a href="bnbah.html">JAXB Examples</a></p>
<p class="toc level4"><a href="bnbah.html#bnbal">JAXB Compiler Options</a></p>
<p class="toc level4"><a href="bnbah.html#bnban">JAXB Schema Generator Option</a></p>
<p class="toc level4"><a href="bnbah.html#bnbao">About the Schema-to-Java Bindings</a></p>
<p class="toc level4"><a href="bnbah.html#bnbar">Schema-Derived JAXB Classes</a></p>
<p class="toc level5"><a href="bnbah.html#bnbas"><tt>Comment</tt> Class</a></p>
<p class="toc level5"><a href="bnbah.html#bnbat"><tt>Items</tt> Class</a></p>
<p class="toc level5"><a href="bnbah.html#bnbau"><tt>ObjectFactory</tt> Class</a></p>
<p class="toc level5"><a href="bnbah.html#bnbav"><tt>PurchaseOrder</tt> Class</a></p>
<p class="toc level5"><a href="bnbah.html#bnbaw"><tt>PurchaseOrderType</tt> Class</a></p>
<p class="toc level5"><a href="bnbah.html#bnbax"><tt>USAddress</tt> Class</a></p>
<div class="onpage">
<p class="toc level3 tocsp"><a href="">Basic JAXB Examples</a></p>
<p class="toc level4"><a href="#bnbaz">Modify Marshal Example</a></p>
<p class="toc level5"><a href="#bnbba">Building and Running the Modify Marshal Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="#bnbbb">Building and Running the Modify Marshal Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="#bnbbc">Unmarshal Validate Example</a></p>
<p class="toc level5"><a href="#bnbbd">Building and Running the Unmarshal Validate Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="#bnbbe">Building and Running the Unmarshal Validate Example Using Ant</a></p>
</div>
<p class="toc level3 tocsp"><a href="bnbbf.html">Customizing JAXB Bindings</a></p>
<p class="toc level4"><a href="bnbbf.html#bnbbg">Why Customize?</a></p>
<p class="toc level4"><a href="bnbbf.html#bnbbh">Customization Overview</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbbi">Inline and External Customizations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbbo">Scope, Inheritance, and Precedence</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbbq">Customization Syntax</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbby">Customization Namespace Prefix</a></p>
<p class="toc level4 tocsp"><a href="bnbbf.html#bnbbz">Customize Inline Example</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbca">Building and Running the Customize Inline Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcb">Building and Running the Customize Inline Example Using Ant</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcc">Customized Schema</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcd">Global Binding Declarations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbce">Schema Binding Declarations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcf">Class Binding Declarations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcg">Property Binding Declarations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbch"><tt>MyDatatypeConverter</tt> Class</a></p>
<p class="toc level4 tocsp"><a href="bnbbf.html#bnbci">Datatype Converter Example</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcj">Building and Running the Datatype Converter Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbck">Building and Running the Datatype Converter Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbbf.html#bnbcl">Binding Declaration Files</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcm">JAXB Version, Namespace, and Schema Attributes</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcq">Global and Schema Binding Declarations</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcr">Class Declarations</a></p>
<p class="toc level4 tocsp"><a href="bnbbf.html#bnbcs">External Customize Example</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbct">Building and Running the External Customize Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbbf.html#bnbcu">Building and Running the External Customize Example Using Ant</a></p>
<p class="toc level3 tocsp"><a href="bnbcv.html">Java-to-Schema Examples</a></p>
<p class="toc level4"><a href="bnbcv.html#bnbcw">Create Marshal Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbcx">Building and Running the Create Marshal Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbcy">Building and Running the Create Marshal Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbcz">XmlAccessorOrder Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbda">Using the <tt>@XmlAccessorOrder</tt> Annotation to Define Schema Element Ordering</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdb">Using the <tt>@XmlType</tt> Annotation to Define Schema Element Ordering</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdc">Schema Content Ordering in the Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdd">Building and Running the XmlAccessorOrder Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbde">Building and Running the XmlAccessorOrder Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbdf">XmlAdapter Field Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdg">Building and Running the XmlAdapter Field Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdh">Building and Running the XmlAdapter Field Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbdi">XmlAttribute Field Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdj">Building and Running the XmlAttribute Field Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdk">Building and Running the XmlAttribute Field Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbdl">XmlRootElement Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdm">Building and Running the XmlRootElement Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdn">Building and Running the XmlRootElement Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbdo">XmlSchemaType Class Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdp">Building and Running the XmlSchemaType Class Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdq">Building and Running the XmlSchemaType Class Example Using Ant</a></p>
<p class="toc level4 tocsp"><a href="bnbcv.html#bnbdr">XmlType Example</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbds">Building and Running the XmlType Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bnbcv.html#bnbdt">Building and Running the XmlType Example Using Ant</a></p>
<p class="toc level3 tocsp"><a href="bnbdu.html">Further Information about JAXB</a></p>
<p class="toc level2 tocsp"><a href="bnbdv.html">18.&nbsp;&nbsp;Streaming API for XML</a></p>
<p class="toc level2"><a href="bnbhf.html">19.&nbsp;&nbsp;SOAP with Attachments API for Java</a></p>
<p class="toc level1 tocsp"><a href="bnblr.html">Part&nbsp;IV&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="bnbls.html">20.&nbsp;&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="bnbnb.html">21.&nbsp;&nbsp;Getting Started with Enterprise Beans</a></p>
<p class="toc level2"><a href="bnboc.html">22.&nbsp;&nbsp;Session Bean Examples</a></p>
<p class="toc level2"><a href="bnbpk.html">23.&nbsp;&nbsp;A Message-Driven Bean Example</a></p>
<p class="toc level1 tocsp"><a href="bnbpy.html">Part&nbsp;V&nbsp;Persistence</a></p>
<p class="toc level2"><a href="bnbpz.html">24.&nbsp;&nbsp;Introduction to the Java Persistence API</a></p>
<p class="toc level2"><a href="bnbrl.html">25.&nbsp;&nbsp;Persistence in the Web Tier</a></p>
<p class="toc level2"><a href="bnbrs.html">26.&nbsp;&nbsp;Persistence in the EJB Tier</a></p>
<p class="toc level2"><a href="bnbtg.html">27.&nbsp;&nbsp;The Java Persistence Query Language</a></p>
<p class="toc level1 tocsp"><a href="bnbwi.html">Part&nbsp;VI&nbsp;Services</a></p>
<p class="toc level2"><a href="bnbwj.html">28.&nbsp;&nbsp;Introduction to Security in the Java EE Platform</a></p>
<p class="toc level2"><a href="bnbyk.html">29.&nbsp;&nbsp;Securing Java EE Applications</a></p>
<p class="toc level2"><a href="bncas.html">30.&nbsp;&nbsp;Securing Web Applications</a></p>
<p class="toc level2"><a href="bncdq.html">31.&nbsp;&nbsp;The Java Message Service API</a></p>
<p class="toc level2"><a href="bncgv.html">32.&nbsp;&nbsp;Java EE Examples Using the JMS API</a></p>
<p class="toc level2"><a href="bncih.html">33.&nbsp;&nbsp;Transactions</a></p>
<p class="toc level2"><a href="bncjh.html">34.&nbsp;&nbsp;Resource Connections</a></p>
<p class="toc level2"><a href="bncjx.html">35.&nbsp;&nbsp;Connector Architecture</a></p>
<p class="toc level1 tocsp"><a href="bnckn.html">Part&nbsp;VII&nbsp;Case Studies</a></p>
<p class="toc level2"><a href="bncko.html">36.&nbsp;&nbsp;The Coffee Break Application</a></p>
<p class="toc level2"><a href="bnclz.html">37.&nbsp;&nbsp;The Duke's Bank Application</a></p>
<p class="toc level1 tocsp"><a href="gexbq.html">Part&nbsp;VIII&nbsp;Appendixes</a></p>
<p class="toc level2"><a href="bncno.html">A.&nbsp;&nbsp;Java Encoding Schemes</a></p>
<p class="toc level2"><a href="bncnq.html">B.&nbsp;&nbsp;Preparation for Java EE Certification Exams</a></p>
<p class="toc level2"><a href="bncnt.html">C.&nbsp;&nbsp;About the Authors</a></p>
<p class="toc level1 tocsp"><a href="idx-1.html">Index</a></p>
</td>
      <td width="10px">&nbsp;</td>
      <td width="705px">
         <div class="header">
             <div class="header-links-top">
                 <a href="http://java.sun.com">java.sun.com</a> |
                 <a href="http://docs.sun.com/">docs.sun.com</a><br>
             </div> 
             <img src="graphics/tutorialBanner.gif" width="704" height="120" alt="The Java&trade; EE 5 Tutorial"/>
             <div class="header-links">
	         <a href="index.html">Home</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/download.html">Download</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/JavaEETutorial.pdf">PDF</a> |
                 <a href="http://java.sun.com/javaee/5/docs/api/index.html">API</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/faq.html">FAQ</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/search.html">Search</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/sendusmail.html">Feedback</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/history.html">History</a>
             </div>
             <div class="navigation">
                 <a href="bnbah.html"><img style="padding-right: 3px" src="graphics/leftButton.gif" border="0"></a>
                 <a href="sjsaseej2eet.html"><img style="padding-right: 3px" src="graphics/upButton.gif" border="0"></a>
                 <a href="bnbbf.html"><img style="padding-left: 3px" src="graphics/rightButton.gif" border="0"></a>
             </div>
         </div>

	 <div class="maincontent">      	 
             

<a name="bnbay"></a><h3>Basic JAXB Examples</h3>
<p>This section describes the Basic examples (Modify Marshal, Unmarshal Validate) that demonstrate how
to:</p>
<ul><li><p>Unmarshal an XML document into a Java content tree and access the data contained within it</p></li>
<li><p>Modify a Java content tree</p></li>
<li><p>Use the <tt>ObjectFactory</tt> class to create a Java content tree from scratch and then marshal it to XML data</p></li>
<li><p>Perform validation during unmarshalling</p></li>
<li><p>Validate a Java content tree at runtime</p></li></ul>


<a name="bnbaz"></a><h4>Modify Marshal Example</h4>
<a name="indexterm-1776"></a><p>The Modify Marshal example demonstrates how to modify a Java content tree.</p>
<ol><li><p>The <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/modify-marshal/src/modifymarshal/Main.java</tt> class declares imports for three standard Java classes plus four JAXB binding framework classes and <tt>primer.po</tt> package:</p><pre>import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import primer.po.*;</pre></li>
<li><p>A <tt>JAXBContext</tt> instance is created for handling classes generated in <tt>primer.po</tt>.</p><pre>JAXBContext jc = JAXBContext.newInstance( "primer.po" );</pre></li>
<li><p>An <tt>Unmarshaller</tt> instance is created, and <tt>po.xml</tt> is unmarshalled.</p><pre>Unmarshaller u = jc.createUnmarshaller();
PurchaseOrder po = (PurchaseOrder)u.unmarshal( new FileInputStream( "po.xml" ) );</pre></li>
<li><p><tt>set</tt> methods are used to modify information in the <tt>address</tt> branch of the content tree.</p><pre>USAddress address = po.getBillTo();
address.setName( "John Bob" );
address.setStreet( "242 Main Street" );
address.setCity( "Beverly Hills" );
address.setState( "CA" );
address.setZip( new BigDecimal( "90210" ) );</pre></li>
<li><p>A <tt>Marshaller</tt> instance is created, and the updated XML content is marshalled to <tt>system.out</tt>. The <tt>setProperty</tt> API is used to specify output encoding; in this case formatted (human readable) XML format.</p><pre>Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal( po, System.out );</pre></li></ol>


<a name="bnbba"></a><h5>Building and Running the Modify Marshal Example Using NetBeans IDE</h5>
<p>Follow these instructions to build and run the Modify Marshal example on your
Application Server instance using the NetBeans IDE.</p>
<ol><li><p>In NetBeans IDE, select File&rarr;Open Project.</p></li>
<li><p>In the Open Project dialog, navigate to <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/</tt>.</p></li>
<li><p>Select the <tt>modify-marshal</tt> folder.</p></li>
<li><p>Select the Open as Main Project check box.</p></li>
<li><p>Click Open Project.</p></li>
<li><p>Right-click the <tt>modify-marshal</tt> project and select Run.</p></li></ol>


<a name="bnbbb"></a><h5>Building and Running the Modify Marshal Example Using Ant</h5>
<p>To compile and run the Modify Marshal example using Ant, in a
terminal window, go to the <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/modify-marshal/</tt> directory and type the following:</p><pre><tt><b>ant runapp</b></tt></pre>

<a name="bnbbc"></a><h4>Unmarshal Validate Example</h4>
<a name="indexterm-1777"></a><p>The Unmarshal Validate example demonstrates how to enable validation during unmarshalling. Note that
JAXB provides functions for validation during unmarshalling but not during marshalling. Validation is
explained in more detail in <a href="bnazg.html#bnazn">More about Validation</a>.</p>
<ol><li><p>The <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/unmarshal-validate/src/unmarshalvalidate/Main.java</tt> class declares imports for three standard Java classes plus seven JAXB binding framework classes and the <tt>primer.po</tt> package:</p><pre>import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.util.ValidationEventCollector;
import primer.po.*;</pre></li>
<li><p>A <tt>JAXBContext</tt> instance is created for handling classes generated in <tt>primer.po</tt>.</p><pre>JAXBContext jc = JAXBContext.newInstance( "primer.po" );</pre></li>
<li><p>An <tt>Unmarshaller</tt> instance is created.</p><pre>Unmarshaller u = jc.createUnmarshaller();</pre></li>
<li><p>The default JAXB <tt>Unmarshaller</tt> <tt>ValidationEventHandler</tt> is enabled to send to validation warnings and errors to <tt>system.out</tt>. The default configuration causes the unmarshal operation to fail upon encountering the first validation error.</p><pre>u.setValidating( true );</pre></li>
<li><p>An attempt is made to unmarshal <tt>po.xml</tt> into a Java content tree. For the purposes of this example, the <tt>po.xml</tt> contains a deliberate error.</p><pre>PurchaseOrder po = (PurchaseOrder)u.unmarshal( new FileInputStream("po.xml"));</pre></li>
<li><p>The default validation event handler processes a validation error, generates output to <tt>system.out</tt>, and then an exception is thrown.</p><pre>} catch( UnmarshalException ue ) {
    System.out.println( "Caught UnmarshalException" );
} catch( JAXBException je ) { 
    je.printStackTrace();
} catch( IOException ioe ) {
    ioe.printStackTrace();
}</pre></li></ol>


<a name="bnbbd"></a><h5>Building and Running the Unmarshal Validate Example Using NetBeans IDE</h5>
<p>Follow these instructions to build and run the Unmarshal Validate example on your
Application Server instance using the NetBeans IDE.</p>
<ol><li><p>In NetBeans IDE, select File&rarr;Open Project.</p></li>
<li><p>In the Open Project dialog, navigate to <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/</tt>.</p></li>
<li><p>Select the <tt>unmarshal-validate</tt> folder.</p></li>
<li><p>Select the Open as Main Project check box.</p></li>
<li><p>Click Open Project.</p></li>
<li><p>Right-click the <tt>unmarshal-validate</tt> project and select Run.</p></li></ol>


<a name="bnbbe"></a><h5>Building and Running the Unmarshal Validate Example Using Ant</h5>
<p>To compile and run the Unmarshal Validate example using Ant, in a
terminal window, go to the <tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/jaxb/unmarshal-validate/</tt> directory and type the following:</p><pre><tt><b>ant runapp</b></tt></pre>
         </div>
         <div class="navigation">
             <a href="bnbah.html"><img style="padding-right: 3px" src="graphics/leftButton.gif" border="0"></a>
             <a href="sjsaseej2eet.html"><img style="padding-right: 3px" src="graphics/upButton.gif" border="0"></a>
             <a href="bnbbf.html"><img style="padding-left: 3px" src="graphics/rightButton.gif" border="0"></a>
         </div>

         <div class="copyright">
      	    <p>The material in The Java&trade; EE 5 Tutorial is <a href='docinfo.html'>copyright</a>-protected and may not be published in other works without express written permission from Sun Microsystems.</p>
      	 </div>

      </td>
   </tr>
</tbody>
</table>
</body>
</html>

